package org.jdk17.example.sun.misc;

import java.lang.reflect.Field;

import sun.misc.Unsafe;

public class UnsafeCreateDemo {
    
    public static void main(String[] args) {
        Unsafe unsafe = UnsafeCreateDemo.getUnsafe();
        System.out.println(unsafe);
    }
    
    public static Unsafe getUnsafe() {
        try {
            Field field = Unsafe.class.getDeclaredField("theUnsafe");
            field.setAccessible(true);
            return (Unsafe) field.get(null);
        } catch (Exception e) {
            System.out.println(e.getMessage());
            return null;
        }
    }
}
